<!DOCTYPE html>
<html lang="en-US">
    <head>
        <title>Digest::MD4 - Perl interface to the MD4 Algorithm - metacpan.org</title>
        <link rel="preload" as="fetch" href="https://metacpan.org/account/login_status" crossorigin="anonymous" />
        <link href="https://metacpan.org/_assets/b8ccceeed47a0652049703d99326a9cea4933443.css" rel="stylesheet" type="text/css">
        <script src="https://metacpan.org/_assets/6bfedafe2d7caa915b7d84f61b45936818e3242e.js" type="text/javascript" defer></script>
        <link rel="alternate" type="application/rss+xml" title="Recent CPAN Uploads of Digest-MD4 - MetaCPAN" href="https://metacpan.org/dist/Digest-MD4/releases.rss" />
        <link rel="canonical" href="./Digest::MD4.html" />
        <meta name="description" content="Perl interface to the MD4 Algorithm" />
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=5">
        <link rel="shortcut icon" href="https://metacpan.org/static/icons/favicon.ico">
        <link rel="apple-touch-icon" sizes="152x152" href="https://metacpan.org/static/icons/apple-touch-icon.png">
        <link rel="search" href="https://metacpan.org/static/opensearch.xml" type="application/opensearchdescription+xml" title="MetaCPAN">
        <script>
          (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
          (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
          m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
          })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

          (function(skey, ga_id){
            ga('create', ga_id, {
              siteSpeedSampleRate : 100,
              storage             : 'none',
              clientId            : localStorage.getItem(skey)
            });
            ga(function(tracker) {
              localStorage.setItem(skey, tracker.get('clientId'));
            });
            ga('send', 'pageview');
          })('ga:clientId', 'UA-27829474-1');
        </script>
<meta name="twitter:card"        content="summary" />
<meta name="twitter:url"         content="https://metacpan.org/pod/Digest::MD4" />
<meta name="twitter:title"       content="Digest::MD4" />
<meta name="twitter:description" content="Perl interface to the MD4 Algorithm" />
<meta name="twitter:site"        content="metacpan" />
    </head>
    <body>
        <nav class="navbar navbar-default" role="navigation">
            <div class="header-logo-large hidden-xs">
              <a href="https://metacpan.org/" tabindex="0">
                <svg class="logo" aria-label="MetaCPAN">
                  <use class="logo" href="/static/images/metacpan-logo.svg#logo" />
                </svg>
              </a>
            </div>
            <div class="header-logo-icon visible-xs">
              <a href="https://metacpan.org/">
                <svg class="logo" aria-label="MetaCPAN">
                  <use class="logo" href="/static/images/metacpan-logo.svg#dots" />
                </svg>
              </a>
            </div>
            <ul class="nav navbar-nav menu-items hidden-xs hidden-sm">
              <li><a href="https://metacpan.org/about">About</a></li>
              <li><a href="https://metacpan.org/about/sponsors">Sponsor</a></li>
              <li><a href="https://grep.metacpan.org/">grep::cpan</a></li>
              <li><a href="https://metacpan.org/recent">Recent</a></li>
              <li><a href="https://metacpan.org/about/faq">FAQ</a></li>
              <li><a href="https://metacpan.org/tools">Tools</a></li>
              <li><a href="https://fastapi.metacpan.org/">API</a></li>
            </ul>
            <ul class="nav navbar-nav navbar-right">
                <button type="button" class="searchbar-btn visible-xs visible-sm">
                    <i class="fa fa-search button-fa-icon"></i>
                </button>
                <form action="https://metacpan.org/search" class="searchbar-form visible-md visible-lg search-form form-horizontal">
                   <input type="hidden" name="size" id="metacpan_search-size" value="20">
                  <div class="form-group">
                      <div class="search-group">
                        <i class="fa fa-search"></i>
                        <input type="text" name="q" placeholder="Search the CPAN" size="41" autocorrect="off" autocapitalize="off" spellcheck="false" id="metacpan_search-input" class="form-control" value="">
                      </div>
                  </div>
                </form>
                    <li class="icon-slidepanel visible-xs visible-sm">
                      <button data-toggle="slidepanel" data-target=".slidepanel">
                        <span class="button-fa-icon">
                          <i class="fa fa-bars slidepanel-open"></i>
                          <i class="fa fa-times slidepanel-close"></i>
                        </span>
                      </button>
                    </li>
                <form action="https://metacpan.org/account/logout" method="POST" id="metacpan-logout"></form>
                <li class="dropdown logged_in" style="display: none;">
                    <button type="button" class="dropdown-toggle" data-toggle="dropdown">
                      <i class="fa fa-user button-fa-icon logged-in-icon" aria-hidden="true"></i>
                      <i class="fas fa-chevron-down"></i>
                    </button>
                    <ul class="dropdown-menu">
                        <li><a href="https://metacpan.org/account/identities">Identities</a></li>
                        <li><a href="https://metacpan.org/account/profile">Profile</a></li>
                        <li><a href="https://metacpan.org/account/favorite/list">Favorites</a></li>
                        <li>
                            <a href="./Digest::MD4.html#" type="button" onclick="$('#metacpan-logout').submit(); return false">
                              Logout
                            </a>
                        </li>
                    </ul>
                </li>
                <li class="dropdown logged_out" style="display: none;">
                    <button type="button" class="dropdown-toggle" data-toggle="dropdown">
                      <i class="fa fa-user button-fa-icon" aria-hidden="true"></i>
                      <i class="fas fa-chevron-down"></i>
                    </button>
                    <ul class="dropdown-menu">
                        <li>
                            <a href="https://metacpan.org/login/github">
                                <i class="fab fa-github fa-fw"></i>
                                GitHub
                            </a>
                        </li>
                        <li>
                            <a href="https://metacpan.org/login/twitter">
                                <i class="fab fa-twitter fa-fw"></i>
                                Twitter
                            </a>
                        </li>
                        <li>
                            <a href="https://metacpan.org/login/google">
                                <i class="fab fa-google fa-fw"></i>
                                Google
                            </a>
                        </li>
                    </ul>
                </li>
                <li class="dropdown logged_placeholder">
                    <button>
                      <i class="fa fa-user button-fa-icon" aria-hidden="true"></i>
                    </button>
                </li>
            </ul>
        </nav>
        <div class="page-content ">
          <!--
          <div class="top-notify-banner">
            <i class="fas fa-info-circle"></i>
          </div>
          -->
          <nav class="sidebar">
            <div class="slidepanel">
              <ul class="nav-list ">
    <li class="nav-header no-margin-top">
      <div class="ttip" data-toggle="tooltip" data-placement="bottom" title="The date that this version of Digest-MD4 was released.">
      <span class="relatize">22 Mar 2013 07:31:20 UTC</span>
    </li>
  <li>
    Distribution: <a href="https://metacpan.org/dist/Digest-MD4">Digest-MD4</a>
  </li>
  <li>
    Module version: 1.9
  </li>
  <li>
    <a data-keyboard-shortcut="g s" href="https://metacpan.org/dist/Digest-MD4/source/MD4.pm">Source</a>
    (<a href="https://metacpan.org/dist/Digest-MD4/source/MD4.pm?raw=1">raw</a>)
  </li>
  <li>
    <a data-keyboard-shortcut="g b" href="https://metacpan.org/dist/Digest-MD4/source">Browse</a>
    (<a href="https://metacpan.org/dist/Digest-MD4/source?raw=1">raw</a>)
  </li>
    <li>
      <a data-keyboard-shortcut="g c" href="https://metacpan.org/dist/Digest-MD4/changes">Changes</a>
    </li>
    <li>
      <a class="nopopup" href="https://metacpan.org/dist/Digest-MD4/contribute">How to Contribute</a>
    </li>
    <li>
      <a rel="noopener nofollow" data-keyboard-shortcut="g i" href="https://rt.cpan.org/Public/Dist/Display.html?Name=Digest-MD4">Issues</a>
      (2)
    </li>
    <li>
      <a rel="noopener nofollow" href="http://matrix.cpantesters.org/?dist=Digest-MD4+1.9" title="Matrix">Testers</a>
        <span title="(pass / fail / na)">(<a rel="noopener nofollow" href="https://www.cpantesters.org/distro/D/Digest-MD4.html?oncpan=1&amp;distmat=1&amp;version=1.9&amp;grade=2" style="color: #090">42</a> / <a rel="noopener nofollow" href="https://www.cpantesters.org/distro/D/Digest-MD4.html?oncpan=1&amp;distmat=1&amp;version=1.9&amp;grade=3" style="color: #900">0</a> / <a rel="noopener nofollow" href="https://www.cpantesters.org/distro/D/Digest-MD4.html?oncpan=1&amp;distmat=1&amp;version=1.9&amp;grade=4">0</a>)</span>
    </li>
    <li>
      <a rel="noopener nofollow" href="http://cpants.cpanauthors.org/release/MIKEM/Digest-MD4-1.9">Kwalitee</a>
    </li>
    <li>
      <div class="ttip" data-toggle="tooltip" data-placement="bottom" title="The # people with an indexing permission on Digest-MD4 who have released something to CPAN in the last 2 years (i.e. the # people likely able to release critical fixes in a timely manner)">
      Bus factor: 1
      </div>
    </li>
    <li>
      <a rel="noopener nofollow" href="http://cpancover.com/latest/Digest-MD4-1.9/index.html">36.36% Coverage </a>
    </li>
    <li>
      License: unknown
    </li>
    <li class="nav-header">Activity</li>
    <li>
<div class="activity-graph">
    <img src="https://metacpan.org/dist/Digest-MD4/activity.svg?res=month" />
    <div class="comment">24 month</div>
</div>
    </li>
    <li class="nav-header">Tools</li>
    <li>
      <a itemprop="downloadUrl" href="https://cpan.metacpan.org/authors/id/M/MI/MIKEM/DigestMD4/Digest-MD4-1.9.tar.gz">
      Download (<span itemprop="fileSize">28.62KB</span>)</a>
    </li>
    <li>
      <a href="https://explorer.metacpan.org/?url=%2Fmodule%2FMIKEM%2FDigest-MD4-1.9%2FMD4.pm">
        MetaCPAN Explorer
      </a>
    </li>
    <li>
      <a href="https://metacpan.org/dist/Digest-MD4/permissions">
        Permissions
      </a>
    </li>
    <li>
      <a href="https://metacpan.org/dist/Digest-MD4/releases.rss">
        Subscribe to distribution
      </a>
    </li>
    <li>
      <button class="btn btn-link" data-toggle="modal" data-target="#metacpan_install-instructions-dialog">
        Install Instructions
      </button>
    </li>
    <li>
      <form action="https://metacpan.org/search">
        <input type="hidden" name="q" value="dist:Digest-MD4">
        <input type="search" name="q" placeholder="Search distribution" class="form-control tool-bar-form">
        <input type="submit" style="display: none">
      </form>
    </li>
    <li>
      <form action="https://grep.metacpan.org/search">
        <input type="hidden" name="qd" value="Digest-MD4">
        <input type="hidden" name="source" value="metacpan">
        <input type="search" name="q" placeholder="grep distribution" class="form-control tool-bar-form">
        <input type="submit" style="display: none">
     </form>
    </li>
    <li class="version-jump">
<select onchange="document.location.href=&#39;/release/&#39;+this.value+&#39;/view/MD4.pm&#39;" class="form-control tool-bar-form">
  <option disabled selected>Jump to version</option>
<option
  disabled
  value="MIKEM/Digest-MD4-1.9"
>1.9
  (MIKEM on 2013-03-22)</option>
<option
  
  value="MIKEM/Digest-MD4-1.8"
>1.8
  (MIKEM on 2013-03-15)</option>
<option
  
  value="MIKEM/Digest-MD4-1.7"
>1.7
  (MIKEM on 2013-03-14)</option>
<option
  
  value="MIKEM/Digest-MD4-1.5"
>1.5
  (MIKEM on 2004-11-17)</option>
<option
  
  value="MIKEM/Digest-MD4-1.4"
>1.4
  (MIKEM on 2004-09-13)</option>
<option
  
  value="MIKEM/Digest-MD4-1.3"
>1.3
  (MIKEM on 2003-11-27)</option>
<option
  
  value="MIKEM/Digest-MD4-1.2"
>1.2
  (MIKEM on 2003-10-30)</option>
<option
  
  value="MIKEM/Digest-MD4-1.1"
>1.1
  (MIKEM on 2001-07-30)</option>
<option
  
  value="MIKEM/Digest-MD4-1.0"
>1.0
  (MIKEM on 2000-08-31)</option>
</select>
    </li>
    <li class="version-diff">
<select onchange="document.location.href='/release/MIKEM/Digest-MD4-1.9/diff/' + encodeURIComponent(this.value) + '/MD4.pm'
" class="form-control tool-bar-form">
  <option disabled selected>Diff with version</option>
<option
  disabled
  value="MIKEM/Digest-MD4-1.9"
>1.9
  (MIKEM on 2013-03-22)</option>
<option
  
  value="MIKEM/Digest-MD4-1.8"
>1.8
  (MIKEM on 2013-03-15)</option>
<option
  
  value="MIKEM/Digest-MD4-1.7"
>1.7
  (MIKEM on 2013-03-14)</option>
<option
  
  value="MIKEM/Digest-MD4-1.5"
>1.5
  (MIKEM on 2004-11-17)</option>
<option
  
  value="MIKEM/Digest-MD4-1.4"
>1.4
  (MIKEM on 2004-09-13)</option>
<option
  
  value="MIKEM/Digest-MD4-1.3"
>1.3
  (MIKEM on 2003-11-27)</option>
<option
  
  value="MIKEM/Digest-MD4-1.2"
>1.2
  (MIKEM on 2003-10-30)</option>
<option
  
  value="MIKEM/Digest-MD4-1.1"
>1.1
  (MIKEM on 2001-07-30)</option>
<option
  
  value="MIKEM/Digest-MD4-1.0"
>1.0
  (MIKEM on 2000-08-31)</option>
</select>
    </li>

    <li>
<ul class="dependencies">
  <li class="nav-header">Dependencies</li>
  <li><a href="https://metacpan.org/pod/File::Spec" title="File::Spec" class="ellipsis">File::Spec</a></li>
  <li><i class="ttip" title="dynamic_config enabled">and possibly others</i></li>
  <li>
    <hr>
  </li>
  <li>
    <a href="https://metacpan.org/module/Digest::MD4/requires">Reverse dependencies</a>
  </li>
  <li>
    <a href="http://deps.cpantesters.org/?module=Digest%3A%3AMD4">CPAN Testers List</a>
  </li>
  <li>
    <a href="https://cpandeps.grinnz.com/?dist=Digest-MD4">Dependency graph</a>
  </li>
</ul>
    </li>
    <li class="nav-header">Permalinks</li>
    <li>
      <a href="https://metacpan.org/release/MIKEM/Digest-MD4-1.9/view/MD4.pm">This version</a>
    </li>
    <li>
      <a href="./Digest::MD4.html">Latest version</a>
    </li>
    <li>
<div class="plussers">
<div class="nav-header">++ed by:</div>
<div>
<a class="display-all" href="https://metacpan.org/author/AYOUNG"><img src="https://www.gravatar.com/avatar/8d1e4946c288fbe87d1e0394f3e41b24?d=identicon&amp;s=20" title="AYOUNG" alt="AYOUNG"></a>
</div>
<!-- Display counts of plussers-->
<div>
    <a href="https://metacpan.org/dist/Digest-MD4/plussers">1 PAUSE user</a>
</div>
</div>
    </li>
    <li>
    </li>
              </ul>
            </div>
          </nav>
          <div class="content-navigation">
<div class="breadcrumbs">
  <span>
    <a data-keyboard-shortcut="g a" rel="author" href="https://metacpan.org/author/MIKEM" class="author-name">Mike McCauley</a>
  </span>
  <span>&nbsp;/&nbsp;</span>
  <div class="release dist-release status-latest maturity-released">
    <span class="dropdown"><b class="caret"></b></span>
<select onchange="document.location.href=&#39;/release/&#39;+this.value+&#39;/view/MD4.pm&#39;" class="">
<option
  selected
  value="MIKEM/Digest-MD4-1.9"
>1.9
  (MIKEM on 2013-03-22)</option>
<option
  
  value="MIKEM/Digest-MD4-1.8"
>1.8
  (MIKEM on 2013-03-15)</option>
<option
  
  value="MIKEM/Digest-MD4-1.7"
>1.7
  (MIKEM on 2013-03-14)</option>
<option
  
  value="MIKEM/Digest-MD4-1.5"
>1.5
  (MIKEM on 2004-11-17)</option>
<option
  
  value="MIKEM/Digest-MD4-1.4"
>1.4
  (MIKEM on 2004-09-13)</option>
<option
  
  value="MIKEM/Digest-MD4-1.3"
>1.3
  (MIKEM on 2003-11-27)</option>
<option
  
  value="MIKEM/Digest-MD4-1.2"
>1.2
  (MIKEM on 2003-10-30)</option>
<option
  
  value="MIKEM/Digest-MD4-1.1"
>1.1
  (MIKEM on 2001-07-30)</option>
<option
  
  value="MIKEM/Digest-MD4-1.0"
>1.0
  (MIKEM on 2000-08-31)</option>
</select>
    <a data-keyboard-shortcut="g d" class="release-name" href="https://metacpan.org/dist/Digest-MD4">Digest-MD4-1.9</a>
  </div>
<span class="river-gauge-gauge">
  <svg width="24px"
       height="15px"
       version="1.1"
       xmlns="http://www.w3.org/2000/svg"
       xmlns:xlink="http://www.w3.org/1999/xlink">

    <g>
      <title>        River stage two &#10;
          • 9 direct dependents &#10;          • 39 total dependents
      </title>

      <rect x="0"  y="0" width="4" height="15" fill="#7ea3f2" />
      <rect x="5"  y="0" width="4" height="15" fill="#7ea3f2" />
      <rect x="10"  y="0" width="4" height="15" fill="#e4e2e2" />
      <rect x="15"  y="0" width="4" height="15" fill="#e4e2e2" />
      <rect x="20"  y="0" width="4" height="15" fill="#e4e2e2" />
    </g>
  </svg>

</span>
<div id="Digest-MD4-fav" class="logged_in">
<form action="https://metacpan.org/account/favorite/add" style="display: inline" onsubmit="return favDistribution(this)">
    <input type="hidden" name="remove" value="0">
    <input type="hidden" name="release" value="Digest-MD4-1.9">
    <input type="hidden" name="author" value="MIKEM">
    <input type="hidden" name="distribution" value="Digest-MD4">
    <button type="submit" class="favorite highlight"><span>1</span> ++</button>
</form>
</div>
<div class="logged_out">
<a href="./Digest::MD4.html" onclick="alert('Please sign in to add favorites'); return false" class="favorite highlight">
<span>1</span> ++</a>
</div>
   / <span>Digest::MD4</span>
</div>
          </div>
          <main class="content">


<nav class="toc">
  <div class="toc-header"><strong>Contents</strong></div>
<ul>
  <li><a href="./Digest::MD4.html#NAME">NAME</a></li>
  <li><a href="./Digest::MD4.html#SYNOPSIS">SYNOPSIS</a></li>
  <li><a href="./Digest::MD4.html#DESCRIPTION">DESCRIPTION</a></li>
  <li><a href="./Digest::MD4.html#FUNCTIONS">FUNCTIONS</a></li>
  <li><a href="./Digest::MD4.html#METHODS">METHODS</a></li>
  <li><a href="./Digest::MD4.html#EXAMPLES">EXAMPLES</a></li>
  <li><a href="./Digest::MD4.html#SEE-ALSO">SEE ALSO</a></li>
  <li><a href="./Digest::MD4.html#COPYRIGHT">COPYRIGHT</a></li>
  <li><a href="./Digest::MD4.html#AUTHORS">AUTHORS</a></li>
</ul></nav>
<div class="pod anchors">
<h1 id="NAME">NAME</h1>

<p>Digest::MD4 - Perl interface to the MD4 Algorithm</p>

<h1 id="SYNOPSIS">SYNOPSIS</h1>

<pre><code> # Functional style
 use Digest::MD4 qw(md4 md4_hex md4_base64);

 $digest = md4($data);
 $digest = md4_hex($data);
 $digest = md4_base64($data);

 # OO style
 use Digest::MD4;

 $ctx = Digest::MD4-&gt;new;

 $ctx-&gt;add($data);
 $ctx-&gt;addfile(*FILE);

 $digest = $ctx-&gt;digest;
 $digest = $ctx-&gt;hexdigest;
 $digest = $ctx-&gt;b64digest;</code></pre>

<h1 id="DESCRIPTION">DESCRIPTION</h1>

<p>The <code>Digest::MD4</code> module allows you to use the RSA Data Security Inc. MD4 Message Digest algorithm from within Perl programs. The algorithm takes as input a message of arbitrary length and produces as output a 128-bit &quot;fingerprint&quot; or &quot;message digest&quot; of the input.</p>

<p>The <code>Digest::MD4</code> module provide a procedural interface for simple use, as well as an object oriented interface that can handle messages of arbitrary length and which can read files directly.</p>

<h1 id="FUNCTIONS">FUNCTIONS</h1>

<p>The following functions are provided by the <code>Digest::MD4</code> module. None of these functions are exported by default.</p>

<dl>

<dt id="md4($data,...)"><a id="md4"></a><a id="md4-data"></a>md4($data,...)</dt>
<dd>

<p>This function will concatenate all arguments, calculate the MD4 digest of this &quot;message&quot;, and return it in binary form. The returned string will be 16 bytes long.</p>

<p>The result of md4(&quot;a&quot;, &quot;b&quot;, &quot;c&quot;) will be exactly the same as the result of md4(&quot;abc&quot;).</p>

</dd>
<dt id="md4_hex($data,...)"><a id="md4_hex"></a><a id="md4_hex-data"></a>md4_hex($data,...)</dt>
<dd>

<p>Same as md4(), but will return the digest in hexadecimal form. The length of the returned string will be 32 and it will only contain characters from this set: &#39;0&#39;..&#39;9&#39; and &#39;a&#39;..&#39;f&#39;.</p>

</dd>
<dt id="md4_base64($data,...)"><a id="md4_base64"></a><a id="md4_base64-data"></a>md4_base64($data,...)</dt>
<dd>

<p>Same as md4(), but will return the digest as a base64 encoded string. The length of the returned string will be 22 and it will only contain characters from this set: &#39;A&#39;..&#39;Z&#39;, &#39;a&#39;..&#39;z&#39;, &#39;0&#39;..&#39;9&#39;, &#39;+&#39; and &#39;/&#39;.</p>

<p>Note that the base64 encoded string returned is not padded to be a multiple of 4 bytes long. If you want interoperability with other base64 encoded md4 digests you might want to append the redundant string &quot;==&quot; to the result.</p>

</dd>
</dl>

<h1 id="METHODS">METHODS</h1>

<p>The object oriented interface to <code>Digest::MD4</code> is described in this section. After a <code>Digest::MD4</code> object has been created, you will add data to it and finally ask for the digest in a suitable format. A single object can be used to calculate multiple digests.</p>

<p>The following methods are provided:</p>

<dl>

<dt id="$md4-=-Digest::MD4-&gt;new"><a id="md4---Digest::MD4--new"></a>$md4 = Digest::MD4-&gt;new</dt>
<dd>

<p>The constructor returns a new <code>Digest::MD4</code> object which encapsulate the state of the MD4 message-digest algorithm.</p>

<p>If called as an instance method (i.e. $md4-&gt;new) it will just reset the state the object to the state of a newly created object. No new object is created in this case.</p>

</dd>
<dt id="$md4-&gt;reset"><a id="md4--reset"></a>$md4-&gt;reset</dt>
<dd>

<p>This is just an alias for $md4-&gt;new.</p>

</dd>
<dt id="$md4-&gt;clone"><a id="md4--clone"></a>$md4-&gt;clone</dt>
<dd>

<p>This a copy of the $md4 object. It is useful when you do not want to destroy the digests state, but need an intermediate value of the digest, e.g. when calculating digests iteratively on a continuous data stream. Example:</p>

<pre><code>    my $md4 = Digest::MD4-&gt;new;
    while (&lt;&gt;) {
        $md4-&gt;add($_);
        print &quot;Line $.: &quot;, $md4-&gt;clone-&gt;hexdigest, &quot;\n&quot;;
    }</code></pre>

</dd>
<dt id="$md4-&gt;add($data,...)"><a id="md4--add-data"></a>$md4-&gt;add($data,...)</dt>
<dd>

<p>The $data provided as argument are appended to the message we calculate the digest for. The return value is the $md4 object itself.</p>

<p>All these lines will have the same effect on the state of the $md4 object:</p>

<pre><code>    $md4-&gt;add(&quot;a&quot;); $md4-&gt;add(&quot;b&quot;); $md4-&gt;add(&quot;c&quot;);
    $md4-&gt;add(&quot;a&quot;)-&gt;add(&quot;b&quot;)-&gt;add(&quot;c&quot;);
    $md4-&gt;add(&quot;a&quot;, &quot;b&quot;, &quot;c&quot;);
    $md4-&gt;add(&quot;abc&quot;);</code></pre>

</dd>
<dt id="$md4-&gt;addfile($io_handle)"><a id="md4--addfile-io_handle"></a>$md4-&gt;addfile($io_handle)</dt>
<dd>

<p>The $io_handle will be read until EOF and its content appended to the message we calculate the digest for. The return value is the $md4 object itself.</p>

<p>The addfile() method will croak() if it fails reading data for some reason. If it croaks it is unpredictable what the state of the $md4 object will be in. The addfile() method might have been able to read the file partially before it failed. It is probably wise to discard or reset the $md4 object if this occurs.</p>

<p>In most cases you want to make sure that the $io_handle is in <code>binmode</code> before you pass it as argument to the addfile() method.</p>

</dd>
<dt id="$md4-&gt;digest"><a id="md4--digest"></a>$md4-&gt;digest</dt>
<dd>

<p>Return the binary digest for the message. The returned string will be 16 bytes long.</p>

<p>Note that the <code>digest</code> operation is effectively a destructive, read-once operation. Once it has been performed, the <code>Digest::MD4</code> object is automatically <code>reset</code> and can be used to calculate another digest value. Call $md4-&gt;clone-&gt;digest if you want to calculate the digest without reseting the digest state.</p>

</dd>
<dt id="$md4-&gt;hexdigest"><a id="md4--hexdigest"></a>$md4-&gt;hexdigest</dt>
<dd>

<p>Same as $md4-&gt;digest, but will return the digest in hexadecimal form. The length of the returned string will be 32 and it will only contain characters from this set: &#39;0&#39;..&#39;9&#39; and &#39;a&#39;..&#39;f&#39;.</p>

</dd>
<dt id="$md4-&gt;b64digest"><a id="md4--b64digest"></a>$md4-&gt;b64digest</dt>
<dd>

<p>Same as $md4-&gt;digest, but will return the digest as a base64 encoded string. The length of the returned string will be 22 and it will only contain characters from this set: &#39;A&#39;..&#39;Z&#39;, &#39;a&#39;..&#39;z&#39;, &#39;0&#39;..&#39;9&#39;, &#39;+&#39; and &#39;/&#39;.</p>

<p>The base64 encoded string returned is not padded to be a multiple of 4 bytes long. If you want interoperability with other base64 encoded md4 digests you might want to append the string &quot;==&quot; to the result.</p>

</dd>
</dl>

<h1 id="EXAMPLES">EXAMPLES</h1>

<p>The simplest way to use this library is to import the md4_hex() function (or one of its cousins):</p>

<pre><code>    use Digest::MD4 qw(md4_hex);
    print &quot;Digest is &quot;, md4_hex(&quot;foobarbaz&quot;), &quot;\n&quot;;</code></pre>

<p>The above example would print out the message:</p>

<pre><code>    Digest is b2b2b528f632f554ae9cb2c02c904eeb</code></pre>

<p>The same checksum can also be calculated in OO style:</p>

<pre><code>    use Digest::MD4;
    
    $md4 = Digest::MD4-&gt;new;
    $md4-&gt;add(&#39;foo&#39;, &#39;bar&#39;);
    $md4-&gt;add(&#39;baz&#39;);
    $digest = $md4-&gt;hexdigest;
    
    print &quot;Digest is $digest\n&quot;;</code></pre>

<p>With OO style you can break the message arbitrary. This means that we are no longer limited to have space for the whole message in memory, i.e. we can handle messages of any size.</p>

<p>This is useful when calculating checksum for files:</p>

<pre><code>    use Digest::MD4;

    my $file = shift || &quot;/etc/passwd&quot;;
    open(FILE, $file) or die &quot;Can&#39;t open &#39;$file&#39;: $!&quot;;
    binmode(FILE);

    $md4 = Digest::MD4-&gt;new;
    while (&lt;FILE&gt;) {
        $md4-&gt;add($_);
    }
    close(FILE);
    print $md4-&gt;b64digest, &quot; $file\n&quot;;</code></pre>

<p>Or we can use the addfile method for more efficient reading of the file:</p>

<pre><code>    use Digest::MD4;

    my $file = shift || &quot;/etc/passwd&quot;;
    open(FILE, $file) or die &quot;Can&#39;t open &#39;$file&#39;: $!&quot;;
    binmode(FILE);

    print Digest::MD4-&gt;new-&gt;addfile(*FILE)-&gt;hexdigest, &quot; $file\n&quot;;</code></pre>

<p>Perl 5.8 support Unicode characters in strings. Since the MD4 algorithm is only defined for strings of bytes, it can not be used on strings that contains chars with ordinal number above 255. The MD4 functions and methods will croak if you try to feed them such input data:</p>

<pre><code>    use Digest::MD4 qw(md4_hex);

    my $str = &quot;abc\x{300}&quot;;
    print md4_hex($str), &quot;\n&quot;;  # croaks
    # Wide character in subroutine entry</code></pre>

<p>What you can do is calculate the MD4 checksum of the UTF-8 representation of such strings. This is achieved by filtering the string through encode_utf8() function:</p>

<pre><code>    use Digest::MD4 qw(md4_hex);
    use Encode qw(encode_utf8);

    my $str = &quot;abc\x{300}&quot;;
    print md4_hex(encode_utf8($str)), &quot;\n&quot;;
    # fc2ef2836f9bc3f44ed6d7adee2f1533</code></pre>

<h1 id="SEE-ALSO"><a id="SEE"></a>SEE ALSO</h1>

<p><a href="https://metacpan.org/pod/Digest">Digest</a>, <a href="./Digest::MD2.html">Digest::MD2</a>, <a href="./Digest::SHA1.html">Digest::SHA1</a>, <a href="./Digest::HMAC.html">Digest::HMAC</a></p>

<p><a href="http://man.he.net/man1/md4sum">md4sum(1)</a></p>

<p>RFC 1320</p>

<h1 id="COPYRIGHT">COPYRIGHT</h1>

<p>This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.</p>

<pre><code> Copyright 1998-2003 Gisle Aas.
 Copyright 1995-1996 Neil Winton.
 Copyright 1991-1992 RSA Data Security, Inc.</code></pre>

<p>The MD4 algorithm is defined in RFC 1320. This implementation is derived from the reference C code in RFC 1320 which is covered by the following copyright statement:</p>

<ul>

<li><p></p>

<pre><code>   Copyright (C) 1990-2, RSA Data Security, Inc. All rights reserved.

   License to copy and use this software is granted provided that it
   is identified as the &quot;RSA Data Security, Inc. MD4 Message-Digest
   Algorithm&quot; in all material mentioning or referencing this software
   or this function.

   License is also granted to make and use derivative works provided
   that such works are identified as &quot;derived from the RSA Data
   Security, Inc. MD4 Message-Digest Algorithm&quot; in all material
   mentioning or referencing the derived work.

   RSA Data Security, Inc. makes no representations concerning either
   the merchantability of this software or the suitability of this
   software for any particular purpose. It is provided &quot;as is&quot;
   without express or implied warranty of any kind.

   These notices must be retained in any copies of any part of this
   documentation and/or software.</code></pre>

</li>
</ul>

<p>This copyright does not prohibit distribution of any version of Perl containing this extension under the terms of the GNU or Artistic licenses.</p>

<h1 id="AUTHORS">AUTHORS</h1>

<p>The original <code>MD5</code> interface was written by Neil Winton (<code>N.Winton@axion.bt.co.uk</code>).</p>

<p>The <code>Digest::MD5</code> module is written by Gisle Aas &lt;gisle@ActiveState.com&gt;.</p>

<p>The <code>Digest::MD4</code> module is derived from Digest::MD5 by Mike McCauley (mikem@airspayce.com)</p></div>

<div id="metacpan_install-instructions-dialog" class="modal fade">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h4 class="modal-title">Module Install Instructions</h4>
      </div>
      <div class="modal-body">
        <p>To install Digest::MD4, copy and paste the appropriate command in to your terminal.</p>
        <p><a href="https://metacpan.org/dist/App-cpanminus/view/bin/cpanm">cpanm</a></p>
        <pre><code>cpanm Digest::MD4</code></pre>
        <p><a href="https://metacpan.org/pod/CPAN">CPAN shell</a></p>
        <pre><code>perl -MCPAN -e shell
install Digest::MD4</code></pre>
        <p>For more information on module installation, please visit <a href="https://www.cpan.org/modules/INSTALL.html">the detailed CPAN module installation guide</a>.</p>
      </div>
      <div class="modal-footer">
        <a href="./Digest::MD4.html#" data-dismiss="modal" class="btn">Close</a>
      </div>
    </div>
  </div>
</div>
          </main>
          <div class="content-pagination">
          </div>
        </div>
        <footer class="footer">
          <div class="footer-container">
            <div class="footer-social">
              <div class="footer-link footer-logo">
                <a href="https://metacpan.org/">
                  <img src="https://metacpan.org/static/images/metacpan-logo.svg" alt="MetaCPAN" />
                </a>
              </div>
              <a class="footer-social-link" href="https://github.com/metacpan">
                <i class="fab fa-github-square"></i>
              </a>
              <a class="footer-social-link" href="https://fosstodon.org/@metacpan">
                <i class="fab fa-mastodon"></i>
              </a>
            </div>
            <div class="footer-links">
              <div class="footer-link">
                  <a href="https://metacpan.org/about">About</a>
              </div>
              <div class="footer-link">
                  <a href="https://metacpan.org/about/sponsors">Sponsor</a>
              </div>
              <div class="footer-link">
                  <a href="https://grep.metacpan.org">grep::cpan</a>
              </div>
              <div class="footer-link">
                  <a href="https://metacpan.org/recent">Recent</a>
              </div>
              <div class="footer-link">
                  <a href="https://metacpan.org/about/faq">FAQ</a>
              </div>
              <div class="footer-link">
                  <a href="https://metacpan.org/tools">Tools</a>
              </div>
              <div class="footer-link">
                  <a href="https://fastapi.metacpan.org/">API</a>
              </div>
              <div class="footer-link">
                  <a href="https://www.perl.org/">Perl.org</a>
              </div>
            </div>
            <div class="footer-sponsors">
              <a class="footer-sponsor-link" target="_blank" href="https://www.bytemark.co.uk/" rel="noopener">
                <img class="footer-sponsor-bytemark" src="https://metacpan.org/static/images/sponsors/bytemark_logo.svg" alt="Bytemark logo">
              </a>
              <a class="footer-sponsor-link" target="_blank" href="https://www.liquidweb.com/" rel="noopener">
                <img class="footer-sponsor-liquidweb" src="https://metacpan.org/static/images/sponsors/liquidweb_logo.png" alt="liquidweb logo">
              </a>
              <a class="footer-sponsor-link" target="_blank" href="https://deriv.com/careers/" rel="noopener">
                <img class="footer-sponsor-deriv" src="https://metacpan.org/static/images/sponsors/deriv.svg" alt="Deriv logo">
              </a>
              <a class="footer-sponsor-link" target="_blank" href="https://geocode.xyz" rel="noopener">
                <img class="footer-sponsor-geocode" src="https://metacpan.org/static/images/sponsors/geocodelogo.svg" alt="Geocode logo">
              </a>
              <a class="footer-sponsor-link" target="_blank" href="https://www.fastly.com/" rel="noopener">
                <img class="footer-sponsor-fastly" src="https://metacpan.org/static/images/sponsors/fastly_logo.svg" alt="Fastly logo">
              </a>
              <a class="footer-sponsor-link" target="_blank" href="https://opencagedata.com" rel="noopener">
                <img class="footer-sponsor-opencage" src="https://metacpan.org/static/images/sponsors/open-cage.svg" alt="OpenCage logo">
              </a>
            </div>
          </div>
        </footer>
        <div class="modal fade" tabindex="-1" role="dialog" id="metacpan_keyboard-shortcuts">
          <div class="modal-dialog">
            <div class="modal-content">
              <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal">&times;</button>
                <h4 class="modal-title">Keyboard Shortcuts</h4>
              </div>
              <div class="modal-body row">
<div class="col-md-6">
  <table class="table keyboard-shortcuts">
    <thead>
      <tr>
        <th></th>
        <th>Global</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td class="keys">
          <kbd>s</kbd>
        </td>
        <td>Focus search bar</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>?</kbd>
        </td>
        <td>Bring up this help dialog</td>
      </tr>
    </tbody>
  </table>

  <table class="table keyboard-shortcuts">
    <thead>
      <tr>
        <th></th>
        <th>GitHub</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>p</kbd>
        </td>
        <td>Go to pull requests</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>i</kbd>
        </td>
        <td>go to github issues (only if github is preferred repository)</td>
      </tr>
    </tbody>
  </table>
</div>

<div class="col-md-6">
  <table class="table keyboard-shortcuts">
    <thead>
      <tr>
        <th></th>
        <th>POD</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>a</kbd>
        </td>
        <td>Go to author</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>c</kbd>
        </td>
        <td>Go to changes</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>i</kbd>
        </td>
        <td>Go to issues</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>d</kbd>
        </td>
        <td>Go to dist</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>r</kbd>
        </td>
        <td>Go to repository/SCM</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>s</kbd>
        </td>
        <td>Go to source</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>b</kbd>
        </td>
        <td>Go to file browse</td>
      </tr>

    </tbody>
  </table>
</div>

<div class="col-md-12">
  <table class="table keyboard-shortcuts">
    <thead>
      <tr>
        <th></th>
        <th>Search terms</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><em>module:</em> (e.g. <a href="https://metacpan.org/search?q=module%3APlugin">module:Plugin</a>)</td>
      </tr>
      <tr>
        <td><em>distribution:</em> (e.g. <a href="https://metacpan.org/search?q=distribution%3ADancer+auth">distribution:Dancer auth</a>)</td>
      </tr>
      <tr>
        <td><em>author:</em> (e.g. <a href="https://metacpan.org/search?q=author%3ASONGMU+Redis">author:SONGMU Redis</a>)</td>
      </tr>
      <tr>
        <td><em>version:</em> (e.g. <a href="https://metacpan.org/search?q=version%3A1.00">version:1.00</a>)</td>
      </tr>
    </tbody>
  </table>
</div>
              </div>
              <div class="modal-footer"></div>
            </div>
          </div>
        </div>
    </body>
</html>
